//
//  UITextField+Category.m
//  Custom
//
//  Created by TT on 2017/4/24.
//  Copyright © 2017年 TT. All rights reserved.
//

#import "UITextField+Category.h"
#import "UILabel+Category.h"

@implementation UITextField (Category)

- (void)setPlaceholderColor:(UIColor *)color{
    [self setValue:color forKeyPath:@"_placeholderLabel.textColor"];
}

+(UITextField *)textFieldWithLeft:(NSString *)left Font:(CGFloat)font
{
    UITextField *temp=[UITextField new];
    if (left.length)
    {
        temp.leftViewMode=UITextFieldViewModeAlways;
        UILabel *label=[UILabel labelWithFont:[UIFont boldSystemFontOfSize:font] textColor:[UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1]];
        CGSize size=[@"验证码" sizeWithAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:(18)]}];
        size.width+=5;
        CGRect rect=label.frame;
        rect.size=size;
        label.frame=rect;
        label.text=left;
        temp.leftView=label;
    }
    temp.textColor=[UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1];
    temp.font=[UIFont systemFontOfSize:(18)];
    return temp;
}

@end

